package com.bjpowernode.boss;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.bjpowernode.boss.dao.entity.DicPayType;
import com.bjpowernode.boss.dao.entity.DicPayWay;
import com.bjpowernode.boss.dao.mapper.DicPayTypeMapper;
import com.bjpowernode.boss.dao.mapper.DicPayWayMapper;
import com.bjpowernode.boss.dao.result.DicEntity;
import jakarta.annotation.Resource;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

import java.util.ArrayList;
import java.util.List;

@MapperScan("com.bjpowernode.boss.dao.mapper")
@SpringBootApplication
public class PowerBossApplication implements CommandLineRunner {

    public List<DicEntity> PAYWAY_DIC_LIST = new ArrayList<>();

    @Resource
    private ApplicationContext applicationContext;

    @Override
    public void run(String... args) throws Exception {
        DicPayWayMapper payWayMapper = applicationContext.getBean(DicPayWayMapper.class);
        PAYWAY_DIC_LIST = payWayMapper.selectPayWayDicList();


    }

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
        // 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
        return interceptor;
    }

    public static void main(String[] args) {
        SpringApplication.run(PowerBossApplication.class, args);
    }

}
